package com.waterfairy.http.utils;

import java.lang.reflect.Field;

import okhttp3.RequestBody;

/**
 * @user water_fairy
 * @mail 995637517@qq.com
 * @date 2021/8/5 4:55 下午
 * @info
 */
public class JsonBodyUtils {
    public static final String MEDIA_TYPE="application/json; charset=utf-8";
    public static String getJsonParams(RequestBody requestBody) {
        //jsonBody
        Class<? extends RequestBody> aClass = requestBody.getClass();
        Field declaredField = aClass.getDeclaredFields()[1];
        declaredField.setAccessible(true);
        byte[] bytes = new byte[0];
        try {
            bytes = (byte[]) declaredField.get(requestBody);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return new String(bytes);
    }
}
